package com.cskaoyan.javase.oop.statickeyword7.introduction1;

/**
 * @description: 全新的版本，用static关键字去升级它
 * @author: wuguidong@cskaoyan.onaliyun.com
 **/

public class NewDemo {
    public static void main(String[] args) {
        //创建学生对象
        NewStudent s1 = new NewStudent("李青云");
        NewStudent s2 = new NewStudent("李青云2");
        NewStudent s3 = new NewStudent("李青云3");

        //静态的成员是对象共享的
        System.out.println(s1.schoolName);
        s1.schoolName = "高考训练营";
        System.out.println(s2.schoolName);
        System.out.println(s3.schoolName);
    }
}

class NewStudent {
    String name;
    String gender;
    int age;
    int stuId;
    //既然学校都是王道训练营,我在这个类的属性定义的时候就给schoolName一个直接的初始值
    static String schoolName = "王道训练营";

    //行为 吃饭和学习
    public void eat() {
        System.out.println("除了学习，就是吃饭！");
    }

    public void study() {
        System.out.println("除了吃饭，就是学习！");
    }

    //提供构造方法


    public NewStudent() {
    }

    public NewStudent(String name, String schoolName) {
        this.name = name;
        this.schoolName = schoolName;
    }

    public NewStudent(String name) {
        this.name = name;
    }
}
